// 支付渠道Mock数据
export interface PaymentChannel {
  channelId: string
  channelName: string
  channelCode: string
  iconUrl: string // 渠道图标URL
  apiUrl: string
  testApiUrl: string // 测试环境API地址
  apiDocUrl: string // 渠道接口文档URL
  supportedProducts: string[]
  settlementCycle: string
  status: number
  isTestMode: boolean
  createdTime: string
  updatedTime: string
  supportProvider: boolean // 是否支持服务商模式
  supportDirect: boolean // 是否支持直连模式
  supportOnboarding: boolean // 是否支持进件
  supportReconciliation: boolean // 是否支持对账
  supportWithdraw: boolean // 是否支持提现
  supportRefund: boolean // 是否支持退款
  supportProfitSharing: boolean // 是否支持分账
  supportTransaction: boolean // 是否支持交易
  extraInfo: Record<string, any> // 额外信息，存储为JSON
}

export const paymentChannels: PaymentChannel[] = [
  {
    channelId: 'CH0001',
    channelName: '微信支付',
    channelCode: 'CHANNEL_IF_WXPAY',
    iconUrl: 'https://anypay-public.oss-cn-shanghai.aliyuncs.com/wx2.svg',
    apiUrl: 'https://api.mch.weixin.qq.com',
    testApiUrl: 'https://api.mch.weixin.qq.com/sandboxnew',
    apiDocUrl: 'https://pay.weixin.qq.com/wiki/doc/apiv3',
    supportedProducts: [
      'WXPAY_NATIVE',  // 微信扫码支付
      'WXPAY_APP',     // 微信APP支付
      'WXPAY_JSAPI',   // 微信小程序支付
      'WXPAY_H5'       // 微信H5支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: true,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: true,
    supportTransaction: true,
    extraInfo: {
      platformCertPath: '/path/to/platform/cert',
      apiVersion: 'v3',
      signType: 'HMAC-SHA256',
      encryptionType: 'AEAD_AES_256_GCM'
    }
  },
  {
    channelId: 'CH0002',
    channelName: '支付宝',
    channelCode: 'CHANNEL_IF_ALIPAY',
    iconUrl: 'https://tianyuankejioss.oss-cn-shanghai.aliyuncs.com/icon/alipay.svg',
    apiUrl: 'https://openapi.alipay.com',
    testApiUrl: 'https://openapi.alipaydev.com',
    apiDocUrl: 'https://opendocs.alipay.com',
    supportedProducts: [
      'ALIPAY_NATIVE',  // 支付宝扫码支付
      'ALIPAY_APP',     // 支付宝APP支付
      'ALIPAY_JSAPI',   // 支付宝小程序支付
      'ALIPAY_H5'       // 支付宝H5支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: true,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: true,
    supportTransaction: true,
    extraInfo: {
      encryptionType: 'AES',
      signType: 'RSA2',
      charset: 'UTF-8',
      format: 'json'
    }
  },
  {
    channelId: 'CH0003',
    channelName: '汇付天下',
    channelCode: 'CHANNEL_IF_HUIFU',
    iconUrl: 'https://tianyuankejioss.oss-cn-shanghai.aliyuncs.com/icon/huifu.svg',
    apiUrl: 'https://api.huifu.com',
    testApiUrl: 'https://api-test.huifu.com',
    apiDocUrl: 'https://docs.huifu.com',
    supportedProducts: [
      'WXPAY_NATIVE',  // 微信扫码支付
      'WXPAY_APP',     // 微信APP支付
      'ALIPAY_NATIVE',  // 支付宝扫码支付
      'ALIPAY_APP'      // 支付宝APP支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-02 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: false,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      signType: 'RSA',
      format: 'json',
      version: '1.0'
    }
  },
  {
    channelId: 'CH0004',
    channelName: '斗拱支付',
    channelCode: 'CHANNEL_IF_DOUGONG',
    iconUrl: 'https://tianyuankejioss.oss-cn-shanghai.aliyuncs.com/icon/dgpay.svg',
    apiUrl: 'https://api.dougong.com',
    testApiUrl: 'https://api-test.dougong.com',
    apiDocUrl: 'https://docs.dougong.com',
    supportedProducts: [
      'WXPAY_NATIVE',  // 微信扫码支付
      'ALIPAY_NATIVE'   // 支付宝扫码支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-03 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: false,
    supportOnboarding: false,
    supportReconciliation: true,
    supportWithdraw: false,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      signType: 'MD5',
      format: 'json'
    }
  },
  {
    channelId: 'CH0005',
    channelName: '富友支付',
    channelCode: 'CHANNEL_IF_FUIOU',
    iconUrl: 'https://anypay-public.oss-cn-shanghai.aliyuncs.com/fuiou.svg',
    apiUrl: 'https://api.fuiou.com',
    testApiUrl: 'https://api-test.fuiou.com',
    apiDocUrl: 'https://docs.fuiou.com',
    supportedProducts: [
      'WXPAY_NATIVE',  // 微信扫码支付
      'WXPAY_APP',     // 微信APP支付
      'WXPAY_H5',      // 微信H5支付
      'ALIPAY_NATIVE',  // 支付宝扫码支付
      'ALIPAY_APP',     // 支付宝APP支付
      'ALIPAY_H5'       // 支付宝H5支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-04 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: false,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      signType: 'RSA',
      version: '2.0'
    }
  },
  {
    channelId: 'CH0006',
    channelName: '拉卡拉',
    channelCode: 'CHANNEL_IF_LAKALA',
    iconUrl: 'https://tianyuankejioss.oss-cn-shanghai.aliyuncs.com/icon/lakala.svg',
    apiUrl: 'https://api.lakala.com',
    testApiUrl: 'https://api-test.lakala.com',
    apiDocUrl: 'https://open.lakala.com',
    supportedProducts: [
      'WXPAY_NATIVE',   // 微信扫码支付
      'WXPAY_APP',      // 微信APP支付
      'ALIPAY_NATIVE',   // 支付宝扫码支付
      'ALIPAY_APP',      // 支付宝APP支付
      'UNIONPAY_CARD'    // 银联刷卡支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-07 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: false,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      signType: 'MD5',
      version: '3.0',
      terminalType: '01'
    }
  },
  {
    channelId: 'CH0007',
    channelName: '乐刷支付',
    channelCode: 'CHANNEL_IF_LESHUA',
    iconUrl: 'https://tianyuankejioss.oss-cn-shanghai.aliyuncs.com/icon/leshua.svg',
    apiUrl: 'https://api.leshua.com',
    testApiUrl: 'https://api-test.leshua.com',
    apiDocUrl: 'https://open.leshua.com',
    supportedProducts: [
      'WXPAY_NATIVE',  // 微信扫码支付
      'WXPAY_APP',     // 微信APP支付
      'WXPAY_JSAPI',   // 微信小程序支付
      'WXPAY_H5',       // 微信H5支付
      'WXPAY_NATIVE',  // 微信扫码支付
      'WXPAY_APP',     // 微信APP支付
      'WXPAY_H5',      // 微信H5支付
      'ALIPAY_NATIVE',  // 支付宝扫码支付
      'ALIPAY_APP',     // 支付宝APP支付
      'ALIPAY_H5',       // 支付宝H5支付
      'ALIPAY_JSAPI'     // 支付宝JSAPI支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-07 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: false,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      signType: 'MD5',
      version: '3.0',
      terminalType: '01'
    }
  },
  {
    channelId: 'CH0008',
    channelName: '银联支付',
    channelCode: 'CHANNEL_IF_UNIONPAY',
    iconUrl: 'https://anypay-public.oss-cn-shanghai.aliyuncs.com/yinlian2.svg',
    apiUrl: 'https://gateway.95516.com',
    testApiUrl: 'https://gateway.test.95516.com',
    apiDocUrl: 'https://open.unionpay.com',
    supportedProducts: [
      'UNIONPAY_CARD',     // 银联刷卡支付
      'UNIONPAY_NATIVE',   // 银联扫码支付
      'UNIONPAY_APP',      // 银联APP支付
      'UNIONPAY_H5'        // 银联H5支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-08 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: true,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: true,
    supportTransaction: true,
    extraInfo: {
      signType: 'RSA2',
      version: '5.1.0',
      encoding: 'UTF-8',
      bizType: '000201'
    }
  },
  {
    channelId: 'CH0009',
    channelName: '易宝支付',
    channelCode: 'CHANNEL_IF_YEEPAY',
    iconUrl: 'https://anypay-public.oss-cn-shanghai.aliyuncs.com/yeepay2.svg',
    apiUrl: 'https://openapi.yeepay.com',
    testApiUrl: 'https://openapi-test.yeepay.com',
    apiDocUrl: 'https://open.yeepay.com',
    supportedProducts: [
      'WXPAY_NATIVE',   // 微信扫码支付
      'WXPAY_APP',      // 微信APP支付
      'ALIPAY_NATIVE',   // 支付宝扫码支付
      'ALIPAY_APP',      // 支付宝APP支付
      'UNIONPAY_CARD',   // 银联刷卡支付
      'YEEPAY_H5'        // 易宝H5支付
    ],
    settlementCycle: 'T+1',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-09 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: true,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      signType: 'RSA2',
      version: '3.0',
      encoding: 'UTF-8',
      merchantType: 'ENTERPRISE'
    }
  },
  {
    channelId: 'CH0010',
    channelName: 'PayPal支付',
    channelCode: 'CHANNEL_IF_PAYPAL',
    iconUrl: 'https://anypay-public.oss-cn-shanghai.aliyuncs.com/paypal.svg',
    apiUrl: 'https://api.paypal.com',
    testApiUrl: 'https://api.sandbox.paypal.com',
    apiDocUrl: 'https://developer.paypal.com',
    supportedProducts: [
      'PAYPAL_EXPRESS',    // PayPal快速支付
      'PAYPAL_CREDIT',     // PayPal信用支付
      'PAYPAL_DEBIT'       // PayPal借记支付
    ],
    settlementCycle: 'T+2',
    status: 1,
    isTestMode: false,
    createdTime: '2024-01-09 10:00:00',
    updatedTime: '2024-01-15 10:00:00',
    supportProvider: true,
    supportDirect: true,
    supportOnboarding: true,
    supportReconciliation: true,
    supportWithdraw: true,
    supportRefund: true,
    supportProfitSharing: false,
    supportTransaction: true,
    extraInfo: {
      apiVersion: 'v2',
      environment: 'live',
      intent: 'sale',
      currency: 'USD'
    }
  }
]

// 渠道配置模板
export const channelConfigTemplate = {
  CHANNEL_IF_WXPAY: {
    required: ['appId', 'mchId', 'apiKey', 'certPath'],
    optional: ['subMchId', 'notifyUrl'],
    modes: ['DIRECT', 'INDIRECT']
  },
  CHANNEL_IF_ALIPAY: {
    required: ['appId', 'pid', 'privateKey', 'publicKey'],
    optional: ['subMchId', 'notifyUrl'],
    modes: ['DIRECT', 'INDIRECT']
  },
  CHANNEL_IF_UNIONPAY: {
    required: ['merId', 'certId', 'privateKey', 'publicKey'],
    optional: ['subMchId', 'notifyUrl', 'backUrl'],
    modes: ['DIRECT', 'INDIRECT']
  },
  CHANNEL_IF_YEEPAY: {
    required: ['merchantId', 'appKey', 'privateKey', 'publicKey'],
    optional: ['subMchId', 'notifyUrl', 'callbackUrl'],
    modes: ['DIRECT', 'INDIRECT']
  },
  CHANNEL_IF_HUIFU: {
    required: ['merchantId', 'apiKey', 'secretKey'],
    optional: ['notifyUrl'],
    modes: ['DIRECT']
  },
  CHANNEL_IF_DOUGONG: {
    required: ['merchantId', 'apiKey', 'secretKey'],
    optional: ['notifyUrl'],
    modes: ['DIRECT']
  },
  CHANNEL_IF_FUIOU: {
    required: ['merchantId', 'apiKey', 'secretKey'],
    optional: ['notifyUrl'],
    modes: ['DIRECT']
  },
  CHANNEL_IF_LAKALA: {
    required: ['merchantId', 'apiKey', 'secretKey'],
    optional: ['notifyUrl'],
    modes: ['DIRECT']
  },
  CHANNEL_IF_PAYPAL: {
    required: ['clientId', 'clientSecret'],
    optional: ['webhookUrl', 'returnUrl', 'cancelUrl'],
    modes: ['DIRECT']
  }
}

// 渠道状态枚举
export const ChannelStatus = {
  DISABLED: 0,
  ENABLED: 1,
  MAINTENANCE: 2,
  TESTING: 3
}

// 获取渠道名称
export const getChannelName = (channelCode: string): string => {
  const channel = paymentChannels.find(c => c.channelCode === channelCode)
  return channel?.channelName || channelCode
}

// 获取渠道状态名称
export const getChannelStatusName = (status: number): string => {
  const statusMap: { [key: number]: string } = {
    0: '禁用',
    1: '启用',
    2: '维护中',
    3: '测试中'
  }
  return statusMap[status] || '未知'
}

// 获取渠道状态颜色
export const getChannelStatusColor = (status: number): string => {
  const colorMap: { [key: number]: string } = {
    0: 'error',
    1: 'success',
    2: 'warning',
    3: 'processing'
  }
  return colorMap[status] || 'default'
}